package com.jimmy.gank;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import com.jimmy.gank.di.component.ActivityComponent;
import com.jimmy.gank.di.component.ApplicationComponent;
import com.jimmy.gank.di.component.DaggerActivityComponent;
import com.jimmy.gank.di.modules.ActivityModule;

public abstract class BaseActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initInject();
    }

    protected abstract void initInject();

    protected ActivityComponent getActivityComponent() {
        ApplicationComponent applicationComponent = ((GankApplication) getApplication()).getComponent();
        return DaggerActivityComponent.builder()
                .applicationComponent(applicationComponent)
                .activityModule(getActivityModule())
                .build();
    }


    private ActivityModule getActivityModule() {
        return new ActivityModule(this);
    }
}
